import csv
import requests
import json


def send_result(testTaskId):
    params_path = '../params.csv'

    with open(params_path, 'r', encoding='utf-8') as csvfile:
        reader = csv.DictReader(csvfile)

        run_result_list = []
        row_count = 0
        for line in reader:
            col_data = line
            json_data = json.dumps(col_data, ensure_ascii=False)
            run_result_list.insert(row_count, json_data)
            row_count += 1
        print(run_result_list)

        send_dict = {'testTaskId': testTaskId, 'run_result_list': run_result_list}
        url = 'http://127.0.0.1:8111/plat/ZtTestTask/sendCaseRuns'
        # requests.post(url, str(run_result_list))
        requests.post(url, str(send_dict))


def test_send():
    send_result(6)
